package edu.psu.geovista.app.pcp.toolkits.gui;
/*
 * TwoSectionPane.java
 *
 * Created on April 9, 2004, 12:32 PM
 *
 * * The panel have 2 sections:
 * - main pane: the content pane
 * - control pane: add control components(e.g.: buttons) here
 *
 * * main pane
 * - Components in this pane is layout in (n,m) n rows and m columns. By default it is (n,1)
 *
 *
 */

import javax.swing.*;
import java.awt.*;

/**
 *
 * @author  jinchen
 */
public class EvenRowSectionsPane extends javax.swing.JPanel {
    private int numrows;
    private int numcols;

    /** Creates new form TwoSectionPane */
    public EvenRowSectionsPane() {
        initComponents();
    }

    public EvenRowSectionsPane(int numrows, int numcols) {
        this.numrows = numrows;
        this.numcols = numcols;
        initComponents();
        this.setLayout(numrows,numcols);
    }

    public void addToMainPane(JComponent cmp){
        mainP.add(cmp);
        mainP.revalidate() ;
    }
    public void addToControlPane(JComponent cmp) {
        controlP.add(cmp);
        controlP.revalidate() ;
    }

    public void clearMainPane(){
        mainP.removeAll();
        mainP.revalidate() ;

    }
    public void clearControlPane(){
        controlP.removeAll();
    }
    public void setLayout(int rows, int cols) {
        clearMainPane();
        GridLayout layout=new GridLayout(rows,cols);
        mainP.setLayout(layout);
        mainP.revalidate() ;
    }

    public JPanel getMainP() {
        return mainP;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        mainP = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        controlP = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();

        setLayout(new java.awt.BorderLayout());

        mainP.setLayout(new java.awt.GridLayout(3, 0));

        mainP.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
        jLabel1.setText("Section 1");
        mainP.add(jLabel1);

        jLabel2.setText("Section2");
        mainP.add(jLabel2);

        jLabel3.setText("Section3");
        mainP.add(jLabel3);

        add(mainP, java.awt.BorderLayout.CENTER);

        controlP.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        jButton1.setText("OK");
        controlP.add(jButton1);

        add(controlP, java.awt.BorderLayout.SOUTH);

    }//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    protected  javax.swing.JPanel controlP;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    protected  javax.swing.JPanel mainP;
    // End of variables declaration//GEN-END:variables
    
}
